package com.example.bootdemo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.bootdemo.dao.SysUserDao;
import com.example.bootdemo.dao.SysUserRoleDao;
import com.example.bootdemo.entity.SysUser;
import com.example.bootdemo.entity.SysUserRole;
import com.example.bootdemo.service.SysUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 系统用户表(SysUser)表服务实现类
 *
 * @author makejava
 * @since 2021-01-06 11:17:08
 */
@Service("sysUserService")
@Slf4j
public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUser> implements SysUserService {
    @Resource
    private SysUserDao sysUserDao;
    @Resource
    private SysUserRoleDao sysUserRoleDao;

    @Override
    public List<String> selectRolesByUserId(Integer userId) {
        log.info("开始执行第一次查询");
        sysUserDao.selectRolesByUserId(userId);
        log.info("开始执行第二次查询");
        sysUserDao.selectRolesByUserId(userId);
        log.info("开始执行第三次查询");
        sysUserDao.selectRolesByUserId(userId);
        log.info("开始执行修改");
        SysUserRole sysUserRole = new SysUserRole();
        sysUserRole.setRoleId(4L);
        sysUserRole.setUserId(1L);
        sysUserRoleDao.insert(sysUserRole);
        log.info("开始执行第四次查询");
        return sysUserDao.selectRolesByUserId(userId);
    }
}